<?php
namespace app\common\model;
use think\Model;

class DeviceStatus extends Model {
	protected $tableName = 'device_status';

	public function addstatus($data){
		$where = array('device_id'=>$data[1]);
		$have = $this->where($where)->find();
		if($have){
			$save['update_time'] = date('Y-m-d H:i:s');
			$save['status'] = '1';
			$where = array('id'=>$have['id']);
			$bool = Model($this->tableName)->where($where)->update($save);
		}else{
			$add['device_id'] = $data[1];
			$add['update_time'] = date('Y-m-d H:i:s');
			$add['status'] = '1';
			$bool = Model($this->tableName)->save($add);
		}
		// dump($bool);
		return $bool;
	}
	public function savestatus($where,$data){
		$bool = 'ok';
		if($data['longitude'] != 0){
			$bool = Model($this->tableName)->where($where)->update($data);

		}
		
		// dump($bool);
		return $bool;
	}
}